//
//  MineActivityController.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/16.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

class MineActivityController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    var tableview:UITableView = UITableView.init()
    let CellId:String = "CELLID"
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUI()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.setNav()
    }
}
extension MineActivityController {
    func setNav(){
        self.navigationItem.title = "活动中心"
        self.navigationController?.navigationBar.barTintColor = .red
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "", imagStr: "ic_back", fontSize: 14, target: self, action: #selector(leftButtonAction))
    }
    func leftButtonAction(){
        self.navigationController!.popViewController(animated: true)
    }
    func setUI(){
        self.view.addSubview(self.tableview)
        self.tableview.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        self.tableview.delegate = self
        self.tableview.dataSource = self
        self.tableview.register(MineActivityCell.self , forCellReuseIdentifier: CellId)
        tableview.separatorStyle = .none
    }
    @objc(tableView:didSelectRowAtIndexPath:) func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("selected")
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    @objc(numberOfSectionsInTableView:) func numberOfSections(in tableView: UITableView) -> Int {
        return 10
    }
    @objc(tableView:heightForRowAtIndexPath:) func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return (120+20+12.5+8+24+14)
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.001
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 12
    }
    @objc(tableView:cellForRowAtIndexPath:) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:MineActivityCell = tableView.dequeueReusableCell(withIdentifier: CellId) as! MineActivityCell
        cell.titleLabel.text = "新的活动"
        cell.dateLabel.text = "2016-12-24"
        cell.selectionStyle = .none
        return cell
    }
}
